From 503d9010f725cd5b6e2d027158713efab622f648 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sat, 9 Feb 2008 21:17:03 +0000 Subject: [PATCH] unicsv: Fix time and date conversions. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3084 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/unicsv.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gpsbabel/unicsv.c b/gpsbabel/unicsv.c index f3f77f0d1..3610927b7 100644 --- a/gpsbabel/unicsv.c +++ b/gpsbabel/unicsv.c @@ -258,15 +258,21 @@ unicsv_parse_date(const char *str, int *consumed) if (consumed && lconsumed) { *consumed = lconsumed; } - is_fatal(ct != 5, MYNAME ": Could not parse date string (%s).", str); + if (ct != 5) { + if (consumed) { /* don't stop here; it's only sniffing */ + *consumed = 0; /* for a possible date */ + return 0; + } + fatal(MYNAME ": Could not parse date string (%s).\n", str); + } if ((p1 > 99) || (sep[0] == '-')) { /* Y-M-D (iso like) */ tm.tm_year = p1; tm.tm_mon = p2; tm.tm_mday = p3; } - else if (sep[0] == '.') { /* Germany any other countries */ - tm.tm_mday = p1; /* have fixed D.M.Y format */ + else if (sep[0] == '.') { /* Germany and any other countries */ + tm.tm_mday = p1; /* have a fixed D.M.Y format */ tm.tm_mon = p2; tm.tm_year = p3; } @@ -280,8 +286,13 @@ unicsv_parse_date(const char *str, int *consumed) else tm.tm_year += 1900; } /* some low-level checks */ - if ((tm.tm_mon > 12) || (tm.tm_mon < 1) || (tm.tm_mday > 31) || (tm.tm_mday < 1)) + if ((tm.tm_mon > 12) || (tm.tm_mon < 1) || (tm.tm_mday > 31) || (tm.tm_mday < 1)) { + if (consumed) { + *consumed = 0; + return 0; /* don't stop here */ + } fatal(MYNAME ": Could not parse date string (%s).\n", str); + } tm.tm_year -= 1900; tm.tm_mon -= 1; -- 2.30.2